# -*- coding: utf-8 -*-
from datetime import timedelta

from jms_hi.ods.tab.tab_reback_transfer_express_hi import jms_ods__tab_reback_transfer_express_hi
from jms_hi.ods.tab.t_del_reback_transfer_info_hi import jms_ods__t_del_reback_transfer_info_hi
from utils.operators.cluster_for_spark_sql_operator import SparkSqlOperator

jms_dwd__dwd_tab_reback_transfer_express_base_hi = SparkSqlOperator(
    task_id='jms_dwd__dwd_tab_reback_transfer_express_base_hi',
    email=['yl_etl@yl-scm.com','yl_bigdata@yl-scm.com'],
    master='yarn',
    name='jms_dwd__dwd_tab_reback_transfer_express_base_hi_{{ execution_date | date_add(1) | cst_ds }}',
    sql='jms_hi/dwd/tab/dwd_tab_reback_transfer_express_base_hi/execute.sql',
    pool_slots=2,
    executor_cores=2,
    executor_memory='4G',
    num_executors=20,
    depends_on_past=True,
    conf={'spark.dynamicAllocation.enabled'                  : 'true',
          'spark.shuffle.service.enabled'                    : 'true',
          'spark.dynamicAllocation.maxExecutors'             : 32,
          # 'spark.dynamicAllocation.maxExecutors'             : 5,
          'spark.dynamicAllocation.cachedExecutorIdleTimeout': 30,
          'spark.sql.sources.partitionOverwriteMode'         : 'dynamic',
          'spark.executor.memoryOverhead'                    : '1G',
          'spark.sql.shuffle.partitions':'300',
          'spark.executor.extraJavaOptions':'-XX:+UseG1GC -XX:ParallelGCThreads=2'
    },
    hiveconf={'hive.exec.dynamic.partition'             : 'true',  # 动态分区
              'hive.exec.dynamic.partition.mode'        : 'nonstrict',
              'hive.exec.max.dynamic.partitions'        : 300,  # 最大分区
              'hive.exec.max.dynamic.partitions.pernode': 300,  # 最大分区
              },
    yarn_queue='pro',
    execution_timeout=timedelta(minutes=40),
)

jms_dwd__dwd_tab_reback_transfer_express_base_hi << [jms_ods__tab_reback_transfer_express_hi,jms_ods__t_del_reback_transfer_info_hi]
